/*
 * @(#)Slot.java	1.0 2000/12/28
 *
 * Copyright 2000 Thomas Barnekow. All Rights Reserved.
 *
 * This software is the proprietary information of Thomas Barnekow.
 * Use is subject to license terms.
 */

package jessx.provider;

import jess.*;
import tb.provider.*;

/**
 * A {@link MetaObject} representing a {@link Deftemplate}'s slot.
 *
 * @author Thomas Barnekow
 * @version 1.0
 */
public class Slot extends AbstractMetaObject {

  private Value m_defaultValue;
  private String m_typeName;

  public Slot(String name, Template template) {
    super(name, template);
  }

  public String getName() {
    return (String) getId();
  }

  public void setDefaultValue(Value value) {
    m_defaultValue = value;
  }

  public Value getDefaultValue() {
    return m_defaultValue;
  }

  public void setTypeName(String value) {
    m_typeName = value;
  }

  public String getTypeName() {
    return m_typeName;
  }

  public String toString() {
    StringBuffer buffer = new StringBuffer(128);

    buffer.append("(slot ").append(getName());
    buffer.append(" (type ").append(m_typeName).append(')');
    if (!m_defaultValue.equals(Funcall.NIL)) {
      buffer.append(" (default ").append(m_defaultValue.toString()).append(')');
    }
    buffer.append(')');

    return buffer.toString();
  }
}